<?xml version='1.0' encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
	<xsl:output
		media-type="text/html"
		method="html"
		indent="yes"
		omit-xml-declaration="yes"
		encoding="UTF-8"
		doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
		doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>

	<xsl:template match="gxpage-error">
		<html>
			<head>
				<title>GXPage System Error</title>
			</head>
			<body>
				<p>GXPage experienced a system error when processing a request.</p>
				<p>Collected errors are below.</p>
				<xsl:call-template name="showMessageList"/>
				<xsl:call-template name="showErrorList"/>
			</body>
		</html>
	</xsl:template>

	<xsl:template name="showMessageList">
		<xsl:variable name="errorList" select="//Messages/*[ type = 'UserNotice' ]"/>
		<xsl:if test="count($errorList) &gt; 0">
			<ul id="Messages">
				<xsl:for-each select="$errorList">
					<li><xsl:value-of select="msg"/></li>
				</xsl:for-each>
			</ul>
		</xsl:if>
	</xsl:template>

	<xsl:template name="showErrorList">
		<xsl:variable name="errorList" select="//Messages/*[ not(type = 'UserNotice') ]"/>
		<xsl:if test="count($errorList) &gt; 0">
			<table border="1">
				<thead>
					<tr>
					<td>Index</td>
					<td>Severity</td>
					<td>Msg</td>
					<td>Debug</td>
					</tr>
				</thead>
				<tbody>
					<xsl:for-each select="$errorList">
						<xsl:sort select="index" data-type="number"/>
						<tr>
							<td><xsl:value-of select="index"/></td>
							<td><xsl:value-of select="type"/></td>
							<td><xsl:value-of select="msg"/></td>
							<td><xsl:value-of select="file"/>::<xsl:value-of select="line"/></td>
						</tr>
					</xsl:for-each>
				</tbody>
			</table>
		</xsl:if>
	</xsl:template>

</xsl:stylesheet>
